import urllib.request
import urllib.error

try:
    headers = {'User_Agent': 'Mozilla/5.0 (X11; Ubuntu;Linux x86_64;rv: 57.0) Gecko / 20100101Firefox / 57.0'}

    response = urllib.request.Request('http://blog.csdn.net/qq_37248504/article/details/106891181', headers=headers)
    html = urllib.request.urlopen(response)
    result=html.read()
    print(result)
except urllib.error.HTTPError as e:
    if hasattr(e,'reason'):
        print('错误原因是'+str(e.reason))
except urllib.error.URLError as e:
    if hasattr(e,'code'):
        print('错误状态吗是'+str(e.code))
else:
    print('请求成功！')
